<?php

class Default_Model_Field extends Zend_Db_Table_Abstract
{
    protected $_name = 'field';
    public function getAllData(){
        $query = $this->select()
                    ->from($this->_name)
                    ->order('fieldId ASC');
        return $this->fetchAll($query);
    }
    public function getDataByID($id)
    {
        $query = $this->select()
                    ->from($this->_name)
                    ->where('fieldId = ?', $id);
        return $this->fetchRow($query)->toArray();
    }
    public function getDataByName($name)
    {
        $query = $this->select()
                    ->from($this->_name)
                    ->where('fieldName = ?', $name);
        return $this->fetchRow($query);
    }
    public function deleteData($id)
    {
        $this->delete('fieldId ='.(int)$id);
    }
    public function addData($fieldName, $type = '')
    {
        $data = array('fieldName' => $fieldName, 'type' => $type);
        return $this->insert($data);
    }
    public function updateData ($fieldId, $fieldName, $type)
    {
        $data = array ( 'fieldName' => $fieldName,'type' => $type );
        $this->update( $data, 'fieldId = ' . (int) $fieldId );
    }
    
}

























